local base = game_mode.localbase
local bg = class("bg_mode",base)

function bg:init()
    base.init(self)
    self.map:brick(720/16,720/16)
    for i = 1, 5 do
        local tank = self:newTank()
        tank:setAI(love.filesystem.read("res/tank.ai"))
        self:setLocalObj(tank)
    end 
end


function bg:newTank()
    local ix,iy
    ix= math.random(3,(self.map.w-3))
    iy= math.random(3,(self.map.h-3))
    self.map:setTile(ix-1,iy,6)
    self.map:setTile(ix,iy,6)
    self.map:setTile(ix,iy-1,6)
    self.map:setTile(ix-1,iy-1,6)
    local tank = Tank(
            self,
            (ix-1)*16, --x
            (iy-1)*16,  --y
            math.random(0,3), --rot
            2, --scale
            math.random(1,4), --team
            math.random(1,8) --type
        )
    return tank
end

return bg